<%@ page language="java"  pageEncoding="utf-8"%>
<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.business.Paper,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@ include file="../include/jsp/head.jsp"%>
<%
if(!globa.userSession.hasRight("10005"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
%>
<%
     //初始化
    Paper  obj0=null;
    Paper obj=new Paper(globa);
    //查询条件

    String strClassTwoAc = ParamUtil.getString(request,"strClassTwoAc","").trim();
	String tWhere=" where 1=1";
	String where = " where 1=1 ";
	String strId = "";
	if(!strClassTwoAc.equals("")){
	 strId = obj.getAcId(" where classTwoAc like '%" + strClassTwoAc + "%'");
	}
	if(!strId.equals("")){
	 tWhere += " and acName = '" + strId + "'";
	 where += " and a.acName = '" + strId + "'";
	}
    	//当前页
	int intCurPage=ParamUtil.getInt(request,"strCurPage");

	//记录总数
	int intAllCount=obj.getCount(tWhere);	

	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集

	Vector<Paper> vctObj=obj.list(where,intStartNum,intPageSize);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	String exportContent = ParamUtil.getString(request,"exportContent","");
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list(where,0,0);
		}
   	   	StringBuffer sb = new StringBuffer();
	    sb.append("城市,区县,一级热点,二级热点\n");
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getStrCity() + ",";
		       strSb += vctObj.get(i).getStrCountry() + ",";
		       strSb += vctObj.get(i).getClssOneAc() + ",";
		       strSb += vctObj.get(i).getClssTwoAc() + ",\n";
		       sb.append(strSb);
		    }
	    }
	    String strFileName = "图纸信息表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
%>
<%@ include file="../include/jsp/footer.jsp"%>
